package com.hw.spark.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hw.spark.model.WordCount;
import com.hw.spark.service.SparkDemo;
import com.hw.spark.service.SparkService;
import com.hw.spark.service.SparkSqlService;

@RestController
public class SparkController {

	@Autowired
    private SparkService sparkService;
	@Autowired
	private SparkDemo sparkdemo;
	@Autowired
	private SparkSqlService sparkSqlService;
 
    @GetMapping("/wordCount")
    public List wordCount() {
        List<WordCount> list = sparkService.doWordCount();
//        return JSONObject.toJSONString(list);
        return list;
    }
    @GetMapping("/demo")
    public void demo() {
    	sparkdemo.demo();
    }
    @GetMapping("/demo1")
    public void demo1() {
    	sparkdemo.demo1();
    }
    @GetMapping("/demo2")
    public void demo2() {
    	sparkdemo.demo2();
    }
    @GetMapping("/sqlFromText")
    public void sqlFromText() {
    	sparkSqlService.sqlFromText();
    }
    @GetMapping("/sqlFromJson")
    public void sqlFromJson() {
    	sparkSqlService.sqlFromJson();
    }
    @GetMapping("/sqlFromDb")
    public void sqlFromDb() {
    	sparkSqlService.sqlFromDb();
    }
}
